package main

import (
	"fmt"
	"strconv"
	"time"
)

func main() {
	//channel声明
	ch := make(chan int)
	//channel的读和写
	//ch <- c 写
	//c:= <-ch 读

	go Read(ch)  //读协程
	go Write(ch) //写协程
	time.Sleep(5)
}

func Read(ch chan int) {
	value := <-ch //从channel读取数据放到value中
	fmt.Println("value---", strconv.Itoa(value))
}

func Write(ch chan int) {
	ch <- 10 //将10写到channel中
}
